#{extends 'master.html' /}
#{set 'title'}
${category.title} - Правка
#{/set}
<h3 class="categoryTitle">${category.title}</h3>
<div class="clear"></div>
<div class="page-block">
    <div class="form">
        <form action="@{CategoryAdmin.update()}">
            <input type="hidden" name="c.id" value="${category.id}"/>
            <fieldset>
                <legend>Основное</legend>
                <div>
                    <label for="title">Название</label>
                    <input type="text" id="title" name="c.title" value="${category.title}"/>
                </div>
            </fieldset>
        </form>
        <fieldset>
            <legend>Псевдонимы</legend>
            <form method="post" action="@{CategoryAdmin.addAlias()}">
                <input type="hidden" name="a.categoryId" value="${category.id}"/>


                <div>
                    <label for="alias">Псевдоним</label>
                    <input type="text" id="alias" name="a.alias"/><input type="submit" value="Добавить">
                </div>

            </form>
            <div>

            #{list items:category.aliases, as:'alias'}
                <div class="removable-item">

                    <form method="post" action="@{CategoryAdmin.deleteAlias(alias.id, category.id)}"><input
                            type="submit" value="Удалить"/></form>
                    <span>${alias.alias}</span>
                </div>
                <div class="clear"></div>
            #{/list}

            </div>
            <div>
                <form method="post" action="@{CategoryAdmin.addImage(category.id)}" enctype="multipart/form-data">
                    <input type="file" name="image" />
                    <input type="submit" value="Добавить">
                </form>
                #{list items:category.images, as:'image'}
                    <img src="@{Image.get(image.id, 'categories')}"/>
                    <form method="post" action="@{CategoryAdmin.deleteImage(category.id, image.id)}">
                        <input type="submit" value="Удалить" />
                    </form>
                #{/list}

            </div>
        </fieldset>
    </div>
</div>